package com.yhb.utils;

import lombok.var;
import me.edzh.spring.bootstrap.processor.SignAndEncryptProcessor;
import me.edzh.spring.bootstrap.utils.ObjectMapperFactory;
import me.edzh.spring.bootstrap.utils.security.RSAUtils;
import okhttp3.*;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import static com.yhb.utils.Constants.RSA_SEGMENT;

public class RequestTest {
    public static String URL_PREFIX = "https://api.ylmvip.cn/";
//    public static String URL_PREFIX = "http://localhost:9329/";

//    public static String TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjb20ueWhiIiwibWUuZWR6aC5zcHJpbmcuYm9vdHN0cmFwLmp3dC51c2VySWQiOiIzNTA4ODE5Zi0wYzg0LTExZWEtOGViZi0wMjQyYWMxMzAwMDMiLCJleHAiOjE1ODE5MTc5Nzd9.4hg0Ke3jVtfbM2p8_r0HcANbDpVfSOgGEwi2sDeVMoA";
//    public static String TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjb20ueWhiIiwibWUuZWR6aC5zcHJpbmcuYm9vdHN0cmFwLmp3dC51c2VySWQiOiI0NDM3NTllZi0xMDBhLTExZWEtYjU0YS0wMDE2M2UwYzhjYjAiLCJleHAiOjE1NzYwNDA2ODZ9.XkLrkC059ivFIT8jA7majiZD6SK-V0OijrDAsv0jysY"; // 吴总
//    public static String TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjb20ueWhiIiwibWUuZWR6aC5zcHJpbmcuYm9vdHN0cmFwLmp3dC51c2VySWQiOiIzNTA4ODE5Zi0wYzg0LTExZWEtOGViZi0wMjQyYWMxMzAwMDMiLCJleHAiOjE1NzU4MTA0OTJ9.1FkMh8eKW1Rm6elQrE4eJYQP-bM3YsCtPDKpuY0QM8Q";
//    public static String TOKEN = null;
    public static String TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZS5lZHpoLnNwcmluZy5ib290c3RyYXAuand0LnVzZXJQcml2aWxlZ2VzIjowLCJpc3MiOiJjb20ueWhiIiwibWUuZWR6aC5zcHJpbmcuYm9vdHN0cmFwLmp3dC51c2VySWQiOiIyNWQ1N2RiNC0wZDQzLTExZWEtYjU0YS0wMDE2M2UwYzhjYjAiLCJleHAiOjE1OTE1MDkyMTB9._g3JDkvZsGIJtRTk0ODBIiNempDycRllGD5SyxSvwHs"; // maple online

//    public static String TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZS5lZHpoLnNwcmluZy5ib290c3RyYXAuand0LnVzZXJQcml2aWxlZ2VzIjowLCJpc3MiOiJjb20ueWhiIiwibWUuZWR6aC5zcHJpbmcuYm9vdHN0cmFwLmp3dC51c2VySWQiOiIyNWQ1N2RiNC0wZDQzLTExZWEtYjU0YS0wMDE2M2UwYzhjYjAiLCJleHAiOjE1OTEzNzU1ODR9.fxlsyn6LLx3epHvMx3yBexVdW7iViRsrSU5IeUGlnss"; // maple local


    public static void main(String[] args) throws Exception {

//        System.out.println(BigDecimal.valueOf(Double.parseDouble("0.5")).divide(BigDecimal.valueOf(100L)).toString());

//        String path = new URL("https://yinhebao-private.oss-cn-shenzhen.aliyuncs.com/891573887343_.pic.jpg").getPath();
//        System.out.println(path.substring(1));
//        testGet("user/1ab05205-f285-11e9-b54a-00163e0c8cb0/info");

//        Map<String, Object> param = new HashMap<>();


//        param.put("id", "f582d560-3dac-11ea-bc66-0242ac130003");
//        testSign("/union/genQR", param);

//        param.put("qrCode", "KN2A4pNwVmjiK3RmS9vY7M4eqfvBV+sMUtywcZiQCpY=");
//        param.put("remitCardId", "8ffea6bc-3db7-11ea-a504-0242ac130003");
//        param.put("amount", 10);
//        testEncrypted("/union/scan", param);

//        param.put("orderId", "dfd02b2d4a4342b6938d0203abca775f");
//        testSign("/union/query", param);
//

//        testSign("user/verifyCode", new HashMap<String, Object>() {{
//            put("mobile", "17796345799");
//        }});

        Map<String, Object> param = new HashMap<>();
//        BigDecimal rate = BigDecimal.valueOf(0.9945);
//        BigDecimal payRate = BigDecimal.ONE
//                .subtract(BigDecimal.ONE.multiply(rate))
//                .multiply(BigDecimal.valueOf(100))
//                .setScale(2, RoundingMode.CEILING);
//        System.out.println(payRate.toString());

//        testEncrypted("test/anyPay/getBalance", param);

//        param.put("mobile", "15989476248");
//        param.put("pwd", "12345678");
//
////        param.put("smsCode", "009331");
////        param.put("uuid", "2876a8ea-7a2f-465d-bbbf-b69d4f5167b7");
//
        String json = "{\"userId\":\"25d57db4-0d43-11ea-b54a-00163e0c8cb0\",\"orderAmount\":23,\"userFeeAmount\":0.06,\"bindCardUUID\":\"633372937b5f47a2b5220583100d91fc\",\"clientIP\":\"183.17.230.8\",\"payRate\":\"\",\"province\":\"广东\",\"city\":\"深圳\",\"area\":\"南山区\",\"payExecutionFlowId\":\"fd5dc744-a715-11ea-bbdb-00163e0c8cb0\",\"payCard\":{\"id\":\"testCardId2\",\"number\":\"6226880207357930\",\"phoneNumber\":\"15989476248\",\"type\":\"CREDIT\",\"cvv2\":\"566\",\"validation\":\"0923\",\"province\":\"广东省\",\"city\":\"深圳市\",\"district\":\"南山区\",\"bankName\":\"中信银行\",\"bankCardImgUrl\":null},\"remitCard\":{\"id\":\"testCardId\",\"number\":\"6216632000000132441\",\"phoneNumber\":\"15989476248\",\"type\":\"DEBIT\",\"province\":\"广东省\",\"city\":\"深圳市\",\"district\":\"南山区\",\"bankName\":\"中国银行\",\"bankCardImgUrl\":null}}";

        param.put("smsCode", "980477");
        param.put("payload", json);
//        testEncrypted("test/anyPay/pay", param);

        testEncrypted("test/anyPay/verifyPay", param);
//        testEncrypted("user/login", param);

//        testEncrypted("test/mapleTest5", param);

//        Map<String, Object> param = new HashMap<>();
//        param.put("mobile", "17796345799");
//        param.put("pwd", "123123123");
//        param.put("inviteCode", "110");
//        param.put("verifyCode", "215211");
//
//        testEncrypted("user/register", param);

//        param.put("id", "1125128c-3e5c-11ea-8b4d-0242ac130002");
//        testSign("/union/getBindCardSms", param);
//
//        param.put("verifyCode", "392143");
//        param.put("token", "3abd5baf-dc96-43fc-be60-a10e363cecd0");
//        testSign("/union/verifyBindCard", param);



//
//        Map<String, Object> param = new HashMap<>();
//        param.put("idCode", "110228197810290033");
//        param.put("name", "吴清宇");
//        param.put("idAvatarUrl", "https://www.google.com");
//        param.put("idEmblemUrl", "https://www.baidu.com");
//        param.put("photoUrl", "https://yinhebao-private.oss-cn-shenzhen.aliyuncs.com/891573887343_.pic.jpg");
//        param.put("validation", "20280214");
////
//        testEncrypted("user/certificate", param);

//        Map<String, Object> plan = new HashMap<>();
//        plan.put("remaining", 10000);
//        plan.put("cardId", "fc01081f-0e80-11ea-81bc-0242ac130003");
//        plan.put("type", "PAYBACK");
//        plan.put("localization", "深圳");
////        testSign("plan/pay/gen", plan);
//        plan.put("flows", "[{\"id\":null,\"planId\":null,\"executionTime\":1574819440095,\"amount\":451,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":2.1197,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574827985095,\"amount\":447.8803,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574834031095,\"amount\":182,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":0.8554,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574840901095,\"amount\":180.1446,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574849742095,\"amount\":947,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":4.4509,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574855925095,\"amount\":941.5491,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574906514095,\"amount\":278,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":1.3066,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574914089095,\"amount\":275.6934,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574920211095,\"amount\":567,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":2.6649,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574927809095,\"amount\":563.3351,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574935235095,\"amount\":133,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":0.6251,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574942070095,\"amount\":131.3749,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574993480095,\"amount\":591,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":2.7777,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1574999080095,\"amount\":587.2223,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575007066095,\"amount\":810,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":3.8070,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575014071095,\"amount\":805.1930,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575021737095,\"amount\":652,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":3.0644,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575028711095,\"amount\":647.9356,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575079440095,\"amount\":468,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":2.1996,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575086353095,\"amount\":464.8004,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575094518095,\"amount\":310,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":1.4570,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575100237095,\"amount\":307.5430,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575107982095,\"amount\":529,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":2.4863,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575115778095,\"amount\":525.5137,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575165374095,\"amount\":987,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":4.6389,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575173012095,\"amount\":981.3611,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575181124095,\"amount\":553,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":2.5991,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575187286095,\"amount\":549.4009,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575195230095,\"amount\":842,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":3.9574,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575200863095,\"amount\":837.0426,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575252360095,\"amount\":173,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":0.8131,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575259567095,\"amount\":171.1869,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575267477095,\"amount\":938,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":4.4086,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575273748095,\"amount\":932.5914,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575281586095,\"amount\":669,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"CONSUME\",\"commission\":3.1443,\"remitFee\":null,\"status\":\"PENDING\"},{\"id\":null,\"planId\":null,\"executionTime\":1575287742095,\"amount\":664.8557,\"cardId\":\"fc01081f-0e80-11ea-81bc-0242ac130003\",\"type\":\"REMIT\",\"commission\":null,\"remitFee\":1,\"status\":\"PENDING\"}]");
//        plan.put("endDate", 1575219925094L);
//        plan.put("days", 6);
////
//        testEncrypted("plan/pay/create", plan);

//
//        Map<String, Object> verifyParam = new HashMap<>();
//        testSign("card/verify", verifyParam);
//
//        Map<String, Object> param = new HashMap<>();
////        param.put("number", "6230580000025083879");
//        param.put("number", "6214867558960119");
//        param.put("type", "DEBIT");
//        param.put("positiveImg", "https://private.static.ylmvip.cn/holdId/20180825100104_19948.jpg");

//        param.put("number", "5187107522634291");
//        param.put("type", "CREDIT");
//        testEncrypted("card/Test", param);
////        param.put("number", "6217770002279085");
////        param.put("type", "DEBIT");
////        param.put("positiveImg", "https://private.static.ylmvip.cn/holdId/20180825100104_19948.jpg");
//
//        param.put("number", "6222350120279466");
//        param.put("type", "CREDIT");
//        testEncrypted("card/bindTest", param);

//        Map<String, Object> param = new HashMap<>();
//        param.put("token", "2cd3ee91-5d2c-4ca2-a27c-87774f3913b2");
//        param.put("verifyCode", "197274");
//        testSign("card/verify", param);


//        Map<String, Object> param = new HashMap<>();
//        param.put("cardId", "fc01081f-0e80-11ea-81bc-0242ac130003");
//        param.put("amount", 100);
//        testEncrypted("card/pay", param);
//        Map<String, Object> param = new HashMap<>();
//        param.put("cardId", "d19a19c1-0e7b-11ea-80bc-0242ac130002");
//        param.put("amount", 98.53);
//        testEncrypted("card/remit", param);



//        Map<String, Object> param = new HashMap<>();
//        param.put("token", "b96b9003-1d91-49e1-8f95-7c9bbc07e417");
//        param.put("verifyCode", "700782");
//        testEncrypted("card/pay", param);



//        param.put("verifyCode", "151460");
//
//        testSign("card/verify", param);

//        Map<String, Object> param = new HashMap<>();
//        param.put("consumeCardId", "cd4c1467-100a-11ea-b54a-00163e0c8cb0");
//        param.put("amount", 146.03);
//        testEncrypted("card/remit", param);
//
//        Map<String, Object> param = new HashMap<>();
//        param.put("consumeCardId", "fc01081f-0e80-11ea-81bc-0242ac130003");
       // param.put("remitCardId", "cd4c1467-100a-11ea-b54a-00163e0c8cb0");
//        param.put("amount", 147);


//        Map<String, Object> param = new HashMap<>();
//        param.put("consumeCardId", "2fcc5cd1-100b-11ea-b54a-00163e0c8cb0");
//        param.put("remitCardId", "cd4c1467-100a-11ea-b54a-00163e0c8cb0");
//        param.put("amount", 147);
//        testEncrypted("trade/commit", param);

//        param.put("remitCardId", "d19a19c1-0e7b-11ea-80bc-0242ac130002");
//        param.put("amount", 1000);
//
//        testEncrypted("trade/commit", param);

//        Map<String, Object> param = new HashMap<>();
//        param.put("token", "a96dca58-94ac-4599-bf5e-93ffaae5c4d3");
//        param.put("verifyCode", "452696");
//        testEncrypted("trade/execute", param);


//        testEncrypted("/test/channel/dispatcher/tryPay", param);
//        testEncrypted("/test/channel/dispatcher/tick", param);
//        param.put("token", "");
//        param.put("smsCode", "");
//        testEncrypted("/test/channel/dispatcher/verifyPay", param);

//        testGet("trade/rapid/1002da22-0ee4-11ea-b125-0242ac130002/query");

//        testGet("plan/pay/72e0f25d-106f-11ea-94f7-0242ac130002");


//        testGet("trade/COMMON_CHANNEL/201901/list");

//        testSign("income/201911/detail", new HashMap<String, Object>(){{
//            put("timeStamp", System.currentTimeMillis());
//        }});

    }

    public static void testSign(String url, Map<String, Object> param) {
        try {
            param.put("timeStamp", "" + System.currentTimeMillis());
            String str = SignAndEncryptProcessor.getParamSignString(param);

            String sign = new SignConfig().sign(str);
//        ObjectMapperFactory.getObjectMapper().
            RequestBody body = RequestBody.create(ObjectMapperFactory.getObjectMapper().writeValueAsString(param), MediaType.parse("application/json;charset-utf8"));
            OkHttpClient client = new OkHttpClient.Builder().build();
            Request r = new Request.Builder()
                    .url(URL_PREFIX + url)
                    .header("SIGN", sign)
                    .header("Authorization", TOKEN)
                    .header("deviceId", "1231290814978178914")
                    .header("gps", "113.59,22.30")
                    .header("deviceType", "1")
                    .post(body)
                    .build();

            System.out.println("start" + System.currentTimeMillis());
            Response resp = client.newCall(r).execute();
            System.out.println("done" + System.currentTimeMillis());

            System.out.println(resp.body().string());
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }

    public static void testEncrypted(String url, Map<String, Object> param) {
        try {
            param.put("timeStamp", "" + System.currentTimeMillis());
            String str = SignAndEncryptProcessor.getParamSignString(param);

            String sign = new SignConfig().sign(str);
//        ObjectMapperFactory.getObjectMapper().
            RequestBody body = RequestBody.create(RSAUtils.encrypt(ObjectMapperFactory.getObjectMapper().writeValueAsString(param).getBytes(), EncryptConfig.publicKey(), RSA_SEGMENT), MediaType.parse("application/json;charset-utf8"));
            OkHttpClient client = new OkHttpClient.Builder().build();
            Request r = new Request.Builder()
                    .url(URL_PREFIX + url)
                    .header("SIGN", sign)
                    .header("Authorization", TOKEN)
                    .header("deviceId", "1231290814978178914")
                    .header("gps", "113.59,22.30")
                    .header("deviceType", "1")
                    .post(body)
                    .build();

            System.out.println("start" + System.currentTimeMillis());
            Response resp = client.newCall(r).execute();
            System.out.println("done" + System.currentTimeMillis());

            System.out.println(resp.body().string());
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }

    public static void testGet(String url) {
        try {
            OkHttpClient client = new OkHttpClient.Builder().build();
            Request r = new Request.Builder()
                    .url(URL_PREFIX + url)
                    .header("Authorization", TOKEN)
                    .header("deviceId", "1231290814978178914")
                    .header("gps", "113.59,22.30")
                    .header("deviceType", "1")
                    .get()
                    .build();

            System.out.println("start" + System.currentTimeMillis());
            Response resp = client.newCall(r).execute();
            System.out.println("done" + System.currentTimeMillis());

            System.out.println(resp.body().string());
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }

}
